<form class="layui-form">
    <input type="hidden" name="bean.id" value="#(bean.id)">
    <input type="hidden" name="bean.orgId" value="#(bean.orgId)">
    <div class="main-container">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">上级</label>
                <div class="layui-input-inline">
                    <input type="text" name="bean.parentId" lay-filter="parent-select" value="#(bean.parentId)" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">类型</label>
                <div class="layui-input-inline">
                <select name="bean.type" lay-filter="" lay-verify="required">
                    <option value="">-- 请选择 --</option>
                #dictList(parentKey="resource_type")
                    #for(dict : dictList)
                    <option value="#(dict.key)" #if(dict.key == bean.type) selected #end>#(dict.value)</option>
                    #end
                #end
                </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="bean.name" value="#(bean.name)" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-inline">
                    <input type="text" id="ID-icon-picker" name="bean.icon" lay-filter="LAY-iconPicker" class="layui-input" value="#(bean.icon)">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">排序</label>
                <div class="layui-input-inline">
                    <input type="text" name="bean.sortNum" lay-verify="required|number" autocomplete="off" class="layui-input" value="#(bean.sortNum)">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="bean.status" value="on" title="启用" #if(bean.status == 'on' || bean.status == null) checked #end>
                    <input type="radio" name="bean.status" value="off" title="禁用" #if(bean.status == 'off') checked #end>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">代码</label>
                <div class="layui-input-inline">
                    <input type="text" name="bean.code" placeholder="" autocomplete="off" class="layui-input" value="#(bean.code)">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">值</label>
            <div class="layui-input-block">
                <textarea placeholder="每一行就是一个值" name="bean.value" class="layui-textarea">#(bean.value)</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea placeholder="" name="bean.remark" class="layui-textarea">#(bean.remark)</textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item" style="display: none;">
        <div class="layui-input-block">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="data-save" id="data-save">
                <i class="layui-icon layui-icon-ok"></i> 提交
            </button>
        </div>
    </div>
</form>
#include("/admin/_common/foot.html")
<script type="text/javascript">
layui.use(['jquery', 'form', 'common', 'iconPicker', 'treeSelect'], function() {
    var $ = layui.jquery;
    var form = layui.form;
    var common = layui.common;
    var iconPicker = layui.iconPicker;
    var treeSelect = layui.treeSelect;
    
    // 模块操作路径
    var MODULE_PATH = "#(ctxPath)/admin/system/resource/";

    // 图标选择
    iconPicker.render({
        elem: '#ID-icon-picker'
        ,type: 'fontClass'
        ,page: true
        ,search: true
        ,limit: 16
        ,click: function(obj){
        },
        ready: function(){
        }
    });

    // 初始化上级下拉选择器
    treeSelect.render({
        elem: '[lay-filter="parent-select"]', // css选择器，推荐使用id
        data: MODULE_PATH + 'tree', // 请求地址
        type: 'get', // ajax请求方式：post/get
        search: true, // 是否开启搜索功能：true/false，默认false
        key: {
            id: 'id', // 返回数据中主键的属性名称，默认值为id
        },
        click: function (data) { // 节点点击回调函数
        },
        style: {
            folder: {
                enable: false
            },
            line: {
                enable: true
            }
        },
        // 加载完成后的回调函数
        success: function (d) {
        	// lay-filter值做为被操作对象ID
            treeSelect.checkNode('parent-select', '#(bean.parentId)');
            treeSelect.refresh('parent-select');
        }
    });
});
</script>
